﻿<UserControl x:Class="ScrumFactory.Proposals.ProposalsList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:SF="clr-namespace:ScrumFactory;assembly=ScrumFactory"
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             xmlns:SF_Converters="clr-namespace:ScrumFactory.Windows.Helpers.Converters;assembly=ScrumFactory.Windows.Helpers"
             xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition" 
             xmlns:props="clr-namespace:ScrumFactory.Proposals.Properties"
             
             x:Name="thisView"
             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <SF_Helpers:PanelLayout Title="{Binding PanelName}"                            
                            SF_Comp:CommandBehavior.RoutedEventName="Loaded"
                            SF_Comp:CommandBehavior.TheCommandToRun="{Binding OnLoadCommand}">

        <!-- TOOLBAR -->
        <SF_Helpers:PanelLayout.Toolbar>
            <ToolBar>
                <MenuItem        
                    x:Name="addProposalButton"
                    Header="{x:Static props:Resources.Add_proposal}"
                    Command="{Binding AddProposalCommand}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/Add.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem                                                     
                    Header="{x:Static props:Resources.Hour_costs}"
                    Command="{Binding ShowHourCostsCommand}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/EditRoles.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem x:Name="showValuesButton" 
                          Header="{x:Static props:Resources.show_hide}" 
                          IsCheckable="True"  
                          IsChecked="{Binding ShowValues}" >
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/alert.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
            </ToolBar>
        </SF_Helpers:PanelLayout.Toolbar>
        
        <SF_Helpers:PanelLayout.Content>
            <Grid>
                
                <ListBox                   
                    HorizontalAlignment="Left"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                    SF_Helpers:ItemActivation.ActivationMode="Both"            
                    SF_Helpers:ItemActivation.TheCommandToRun="{Binding ShowDetailCommand}"      
                    ItemContainerStyle="{StaticResource NoSelectionListBoxItem}"
                    ItemsSource="{Binding Proposals}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Width="450">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Image
                                Grid.Column="0" Grid.RowSpan="3" VerticalAlignment="Top"
                                DataContext="{Binding ProposalStatus}" Margin="5"
                                Style="{StaticResource ProposalStatusImage}"/>
                                <TextBlock
                                Grid.Column="1" Grid.Row="0">
                                    <Hyperlink
                                        Command="{Binding Model.ShowDetailCommand, ElementName=thisView}"
                                        CommandParameter="{Binding .}">
                                        <TextBlock Text="{Binding ProposalName}" FontSize="{StaticResource BigFontSize}"/>
                                    </Hyperlink>
                                </TextBlock>

                                <TextBlock Grid.Column="1" Grid.Row="1">
                                    <!--<TextBlock FontSize="{StaticResource ReallyBigFontSize}" Text="{Binding CurrencySymbol}"/>-->
                                    <TextBlock FontSize="{StaticResource ReallyBigFontSize}" Text="{Binding TotalValue, StringFormat='{}{0:C}'}"/>
                                </TextBlock>

                                <TextBlock Grid.Column="1" Grid.Row="2">                                    
                                    <TextBlock                                         
                                        Text="{Binding ApprovalDate, StringFormat={x:Static props:Resources.at_D}}"/>
                                    <TextBlock                                         
                                        Text="{Binding ApprovedBy, StringFormat={x:Static props:Resources.by_W}}"/>
                                    <LineBreak/>
                                    <TextBlock DataContext="{Binding RejectReason, Converter={StaticResource ShortToEnumConverter}, ConverterParameter={x:Type SF:ProposalRejectReasons}}"
                                        Text="{Binding ., Converter={StaticResource LocalizeConverter}}"/>
                                    <TextBlock.Style>
                                        <Style>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ProposalStatus}" Value="0">
                                                    <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding ProposalStatus}" Value="2">
                                                    <Setter Property="TextBlock.Foreground" Value="{StaticResource AlertBrush}"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>

                                

                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.Style>
                        <Style TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=showValuesButton, Path=IsChecked}" Value="False">
                                    <Setter Property="ListBox.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ListBox.Style>
                </ListBox>

                <ContentControl
                    Style="{StaticResource LoadingAnimationContent}"/>

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Image Source="/Images/information.png"  Width="16" Height="16" Margin="0,0,10,0"/>
                    <TextBlock Text="{x:Static props:Resources.show_hide_tip}" />                    
                    <StackPanel.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=showValuesButton, Path=IsChecked}" Value="True">
                                    <Setter Property="StackPanel.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </StackPanel.Style>
                </StackPanel>
                

                
            </Grid>
            
        </SF_Helpers:PanelLayout.Content>
        
        
        
    </SF_Helpers:PanelLayout>
</UserControl>
